# encoding:utf-8
"""
===============***===============
Auther : Hsir
Date   : 2022 - 11 - 22   14:58
File   : pubilic_api.py
===============***===============
"""
from configparser import ConfigParser
import yaml
from autotest04.comms.constants import INI_DIR


"""
封装yaml测试数据获取
封装解析器获取ini配置文件对应值
"""


def get_yaml_data(file):
    try:
        with open(file, mode='r', encoding='utf-8') as fr:
            cases = yaml.safe_load(fr)
        return cases
    except Exception as e:
        print("从yaml文件读取测试数据失败!", e)


def get_ini_data(section, option):
    try:
        cp = ConfigParser()  # 创建 解析器对象
        cp.read(INI_DIR, encoding="utf-8")  # 加载ini文件
        result = cp.get(section, option)  # 通过 标头和选项获取对应的值
        return result
    except Exception as e:
        print("从ini文件中读取数据失败", e)



